class Solution {
public:
    int maxArea(vector<int>& height)
    {
        int left = 0, right = height.size() - 1;
        int minH = (height[left] > height[right] ? height[right] : height[left]);
        int sum = (height.size() - 1) * minH;

        while (left < right)
        {
            height[left] < height[right] ? left++ : right--;
            minH = (height[left] > height[right] ? height[right] : height[left]);
            int newsum = (right - left) * minH;
            //std::cout<<left<<" "<<right<<newsum<<endl;
            if (newsum > sum)
            {

                sum = newsum;
            }
            //cout<<sum<<endl;

        }
        return sum;



    }
};